<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>25.3. Normalization and Localization</title>
<link rel="stylesheet" href="dbstyle.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
<link rel="start" href="index.html" title="Programmer's Reference Guide">
<link rel="up" href="zend.locale.html" title="Chapter 25. Zend_Locale">
<link rel="prev" href="zend.locale.functions.html" title="25.2. Using Zend_Locale">
<link rel="next" href="zend.locale.date.datesandtimes.html" title="25.4. Working with Dates and Times">
<link rel="chapter" href="introduction.html" title="Chapter 1. Introduction to Zend Framework">
<link rel="chapter" href="zend.acl.html" title="Chapter 2. Zend_Acl">
<link rel="chapter" href="zend.auth.html" title="Chapter 3. Zend_Auth">
<link rel="chapter" href="zend.cache.html" title="Chapter 4. Zend_Cache">
<link rel="chapter" href="zend.config.html" title="Chapter 5. Zend_Config">
<link rel="chapter" href="zend.console.getopt.html" title="Chapter 6. Zend_Console_Getopt">
<link rel="chapter" href="zend.controller.html" title="Chapter 7. Zend_Controller">
<link rel="chapter" href="zend.currency.html" title="Chapter 8. Zend_Currency">
<link rel="chapter" href="zend.date.html" title="Chapter 9. Zend_Date">
<link rel="chapter" href="zend.db.html" title="Chapter 10. Zend_Db">
<link rel="chapter" href="zend.debug.html" title="Chapter 11. Zend_Debug">
<link rel="chapter" href="zend.dojo.html" title="Chapter 12. Zend_Dojo">
<link rel="chapter" href="zend.dom.html" title="Chapter 13. Zend_Dom">
<link rel="chapter" href="zend.exception.html" title="Chapter 14. Zend_Exception">
<link rel="chapter" href="zend.feed.html" title="Chapter 15. Zend_Feed">
<link rel="chapter" href="zend.filter.html" title="Chapter 16. Zend_Filter">
<link rel="chapter" href="zend.form.html" title="Chapter 17. Zend_Form">
<link rel="chapter" href="zend.gdata.html" title="Chapter 18. Zend_Gdata">
<link rel="chapter" href="zend.http.html" title="Chapter 19. Zend_Http">
<link rel="chapter" href="zend.infocard.html" title="Chapter 20. Zend_InfoCard">
<link rel="chapter" href="zend.json.html" title="Chapter 21. Zend_Json">
<link rel="chapter" href="zend.layout.html" title="Chapter 22. Zend_Layout">
<link rel="chapter" href="zend.ldap.html" title="Chapter 23. Zend_Ldap">
<link rel="chapter" href="zend.loader.html" title="Chapter 24. Zend_Loader">
<link rel="chapter" href="zend.locale.html" title="Chapter 25. Zend_Locale">
<link rel="chapter" href="zend.log.html" title="Chapter 26. Zend_Log">
<link rel="chapter" href="zend.mail.html" title="Chapter 27. Zend_Mail">
<link rel="chapter" href="zend.measure.html" title="Chapter 28. Zend_Measure">
<link rel="chapter" href="zend.memory.html" title="Chapter 29. Zend_Memory">
<link rel="chapter" href="zend.mime.html" title="Chapter 30. Zend_Mime">
<link rel="chapter" href="zend.openid.html" title="Chapter 31. Zend_OpenId">
<link rel="chapter" href="zend.paginator.html" title="Chapter 32. Zend_Paginator">
<link rel="chapter" href="zend.pdf.html" title="Chapter 33. Zend_Pdf">
<link rel="chapter" href="zend.registry.html" title="Chapter 34. Zend_Registry">
<link rel="chapter" href="zend.rest.html" title="Chapter 35. Zend_Rest">
<link rel="chapter" href="zend.search.lucene.html" title="Chapter 36. Zend_Search_Lucene">
<link rel="chapter" href="zend.server.html" title="Chapter 37. Zend_Server">
<link rel="chapter" href="zend.service.html" title="Chapter 38. Zend_Service">
<link rel="chapter" href="zend.session.html" title="Chapter 39. Zend_Session">
<link rel="chapter" href="zend.soap.html" title="Chapter 40. Zend_Soap">
<link rel="chapter" href="zend.test.html" title="Chapter 41. Zend_Test">
<link rel="chapter" href="zend.text.html" title="Chapter 42. Zend_Text">
<link rel="chapter" href="zend.timesync.html" title="Chapter 43. Zend_TimeSync">
<link rel="chapter" href="zend.translate.html" title="Chapter 44. Zend_Translate">
<link rel="chapter" href="zend.uri.html" title="Chapter 45. Zend_Uri">
<link rel="chapter" href="zend.validate.html" title="Chapter 46. Zend_Validate">
<link rel="chapter" href="zend.version.html" title="Chapter 47. Zend_Version">
<link rel="chapter" href="zend.view.html" title="Chapter 48. Zend_View">
<link rel="chapter" href="zend.xmlrpc.html" title="Chapter 49. Zend_XmlRpc">
<link rel="appendix" href="requirements.html" title="Appendix A. Zend Framework Requirements">
<link rel="appendix" href="coding-standard.html" title="Appendix B. Zend Framework Coding Standard for PHP">
<link rel="appendix" href="copyrights.html" title="Appendix C. Copyright Information">
<link rel="index" href="the.index.html" title="Index">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.number.normalize" title="25.3.1. Number normalization: getNumber($input, Array $options)">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.number.localize" title="25.3.2. Number localization">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.number.test" title="25.3.3. Number testing">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.float.normalize" title="25.3.4. Float value normalization">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.float.localize" title="25.3.5. Floating point value localization">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.float.test" title="25.3.6. Floating point value testing">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.integer.normalize" title="25.3.7. Integer value normalization">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.integer.localize" title="25.3.8. Integer point value localization">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.integer.test" title="25.3.9. Integer value testing">
<link rel="subsection" href="zend.locale.parsing.html#zend.locale.numbersystems" title="25.3.10. Numeral System Conversion">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader"><table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">25.3. Normalization and Localization</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="zend.locale.functions.html">Prev</a> </td>
<th width="60%" align="center">Chapter 25. Zend_Locale</th>
<td width="20%" align="right"> <a accesskey="n" href="zend.locale.date.datesandtimes.html">Next</a>
</td>
</tr>
</table></div>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="zend.locale.parsing"></a>25.3. Normalization and Localization</h2></div></div></div>
<p>
        <code class="code">Zend_Locale_Format</code> is a internal component used by Zend_Locale. All locale aware classes use
        <code class="code">Zend_Locale_Format</code> for normalization and localization of numbers and dates. Normalization involves
        parsing input from a variety of data respresentations, like dates, into a standardized, structured
        representation, such as a PHP array with year, month, and day elements.
    </p>
<p>
        The exact same string containing a number or a date might mean different things to people with different customs
        and conventions. Disambiguation of numbers and dates requires rules about how to interpret these strings and
        normalize the values into a standardized data structure. Thus, all methods in <code class="code">Zend_Locale_Format</code>
        require a locale in order to parse the input data.
        </p>
<div class="note"><table border="0" summary='Note: Default "root" Locale'>
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Default "root" Locale</th>
</tr>
<tr><td align="left" valign="top"><p>
                If no locale is specified, then normalization and localization will use the standard "root" locale,
                which might yield unexpected behavior, if the input originated in a different locale, or output for a
                specific locale was expected.
            </p></td></tr>
</table></div>
<p>
    </p>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.number.normalize"></a>25.3.1. Number normalization: getNumber($input, Array $options)</h3></div></div></div>
<p>
            There are many
            <a href="http://en.wikipedia.org/wiki/Numeral" target="_top">number systems</a>
            different from the common
            <a href="http://en.wikipedia.org/wiki/Decimal" target="_top">decimal system</a>
            (e.g. "3.14"). Numbers can be normalized with the <code class="code">getNumber()</code> function to obtain the standard
            decimal representation. For all number-related discussions in this manual,
            <a href="http://en.wikipedia.org/wiki/Arabic_numerals" target="_top">Arabic/European numerals (0,1,2,3,4,5,6,7,8,9)</a>
            are implied, unless explicitly stated otherwise. The options array may contain a 'locale' to define grouping
            and decimal characters. The array may also have a 'precision' to truncate excess digits from the result.
        </p>
<div class="example">
<a name="zend.locale.number.normalize.example-1"></a><p class="title"><b>Example 25.23. Number normalization</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::getNumber('13.524,678', array('locale' =&gt; $locale, 'precision' =&gt; 3));

print $number; // will return 13524.678
            </pre></div>
</div>
<br class="example-break"><div class="sect3" lang="en">
<div class="titlepage"><div><div><h4 class="title">
<a name="zend.locale.number.normalize.precision"></a>25.3.1.1. Precision and Calculations</h4></div></div></div>
<p>
                Since <code class="code">getNumber($value, array $options = array())</code> can normalize extremely large numbers,
                check the result carefully before using finite precision calculations, such as ordinary PHP math
                operations. For example, <code class="code">if ((string)int_val($number) != $number) { use
                <a href="http://www.php.net/bc" target="_top">BCMath</a>
                or
                <a href="http://www.php.net/gmp" target="_top">GMP</a>
                </code>. Most PHP installations support the BCMath extension.
            </p>
<p>
                Also, the precision of the resulting decimal representation can be rounded to a desired length with
                <code class="code">getNumber()</code> with the option <code class="code">'precision'</code>. If no precision is given,
                no rounding occurs. Use only PHP integers to specify the precision.
            </p>
<p>
                If the resulting decimal representation should be truncated to a desired length instead of rounded
                the option <code class="code">'number_format'</code> can be used instead. Define the length of the decimal
                representation with the desired length of zeros. The result will then not be rounded.
                So if the defined precision within <code class="code">number_format</code> is zero the value "1.6" will
                return "1", not "2. See the example nearby:
            </p>
<div class="example">
<a name="zend.locale.number.normalize.precision.example-1"></a><p class="title"><b>Example 25.24. Number normalization with precision</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::getNumber('13.524,678', array('precision' =&gt; 1, 'locale' =&gt; $locale));
print $number; // will return 13524.7

$number = Zend_Locale_Format::getNumber('13.524,678', array('number_format' =&gt; '#.00', 'locale' =&gt; $locale));
print $number; // will return 13524.67
                </pre></div>
</div>
<br class="example-break">
</div>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.number.localize"></a>25.3.2. Number localization</h3></div></div></div>
<p>
            <code class="code">toNumber($value, array $options = array())</code> can localize numbers to the
            <a href="zend.locale.regions.html" title="25.6. Supported Regions for Locales">supported locales</a>
            . This function will return a localized string of the given number in a conventional format for a specific
            locale. The 'number_format' option explicitly specifies a non-default number format for use with
            <code class="code">toNumber()</code>.
        </p>
<div class="example">
<a name="zend.locale.number.localize.example-1"></a><p class="title"><b>Example 25.25. Number localization</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::toNumber(13547.36, array('locale' =&gt; $locale));

// will return 13.547,36
print $number;
            </pre></div>
</div>
<br class="example-break"><p>
            </p>
<div class="note"><table border="0" summary="Note: Unlimited length">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Unlimited length</th>
</tr>
<tr><td align="left" valign="top"><p>
                    <code class="code">toNumber()</code> can localize numbers with unlimited length. It is not related to integer or
                    float limitations.
                </p></td></tr>
</table></div>
<p>
        </p>
<p>
            The same way as within <code class="code">getNumber()</code>, <code class="code">toNumber()</code> handles precision. If no precision
            is given, the complete localized number will be returned.
        </p>
<div class="example">
<a name="zend.locale.number.localize.example-2"></a><p class="title"><b>Example 25.26. Number localization with precision</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::toNumber(13547.3678, array('precision' =&gt; 2, 'locale' =&gt; $locale));

// will return 13.547,37
print $number;
            </pre></div>
</div>
<br class="example-break"><p>
            Using the option 'number_format' a self defined format for generating a number can be defined.
            The format itself has to be given in CLDR format as described below. The locale is used to get
            seperation, precission and other number formatting signs from it. German for example defines
            ',' as precission seperation and in english the '.' sign is used.
        </p>
<div class="table">
<a name="zend.locale.number.localize.table-1"></a><p class="title"><b>Table 25.4. Format tokens for self generated number formats
            </b></p>
<div class="table-contents"><table summary="Format tokens for self generated number formats
            " border="1">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>Token</th>
<th>Description</th>
<th>Example format</th>
<th>Generated output</th>
</tr></thead>
<tbody>
<tr>
<td>#0</td>
<td>Generates a number without precission and seperation</td>
<td>#0</td>
<td>1234567</td>
</tr>
<tr>
<td>,</td>
<td>Generates a seperation with the length from seperation to next seperation or to 0</td>
<td>#,##0</td>
<td>1,234,567</td>
</tr>
<tr>
<td>#,##,##0</td>
<td>Generates a standard seperation of 3 and all following seperations with 2</td>
<td>#,##,##0</td>
<td>12,34,567</td>
</tr>
<tr>
<td>.</td>
<td>Generates a precission</td>
<td>#0.#</td>
<td>1234567.1234</td>
</tr>
<tr>
<td>0</td>
<td>Generates a precission with a defined length</td>
<td>#0.00</td>
<td>1234567.12</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="example">
<a name="zend.locale.number.localize.example-3"></a><p class="title"><b>Example 25.27. Using a self defined number format</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::toNumber(13547.3678, array('number_format' =&gt; '#,#0.00', 'locale' =&gt; 'de'));

// will return 1.35.47,36
print $number;

$number = Zend_Locale_Format::toNumber(13547.3, array('number_format' =&gt; '#,##0.00', 'locale' =&gt; 'de'));

// will return 13.547,30
print $number;
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.number.test"></a>25.3.3. Number testing</h3></div></div></div>
<p>
            <code class="code">isNumber($value, array $options = array())</code> checks if a given string is a number and returns
            true or false.
        </p>
<div class="example">
<a name="zend.locale.number.test.example-1"></a><p class="title"><b>Example 25.28. Number testing</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale();
if (Zend_Locale_Format::isNumber('13.445,36', array('locale' =&gt; 'de_AT')) {
    print "Number";
} else {
    print "not a Number";
}
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.float.normalize"></a>25.3.4. Float value normalization</h3></div></div></div>
<p>
            Floating point values can be parsed with the <code class="code">getFloat($value, array $options = array())</code>
            function. A floating point value will be returned.
        </p>
<div class="example">
<a name="zend.locale.float.normalize.example-1"></a><p class="title"><b>Example 25.29. Floating point value normalization</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::getFloat('13.524,678', array('precision' =&gt; 2, 'locale' =&gt; $locale));

// will return 13524.68
print $number;
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.float.localize"></a>25.3.5. Floating point value localization</h3></div></div></div>
<p>
            <code class="code">toFloat()</code> can localize floating point values. This function will return a localized string of
            the given number.
        </p>
<div class="example">
<a name="zend.locale.float.localize.example-1"></a><p class="title"><b>Example 25.30. Floating point value localization</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::toFloat(13547.3655, array('precision' =&gt; 1, 'locale' =&gt; $locale));

// will return 13.547,4
print $number;
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.float.test"></a>25.3.6. Floating point value testing</h3></div></div></div>
<p>
            <code class="code">isFloat($value, array $options = array())</code> checks if a given string is a floating point value
            and returns true or false.
        </p>
<div class="example">
<a name="zend.locale.float.test.example-1"></a><p class="title"><b>Example 25.31. Floating point value testing</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
if (Zend_Locale_Format::isFloat('13.445,36', array('locale' =&gt; $locale)) {
    print "float";
} else {
    print "not a float";
}
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.integer.normalize"></a>25.3.7. Integer value normalization</h3></div></div></div>
<p>
            Integer values can be parsed with the <code class="code">getInteger()</code> function. A integer value will be returned.
        </p>
<div class="example">
<a name="zend.locale.integer.normalize.example-1"></a><p class="title"><b>Example 25.32. Integer value normalization</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::getInteger('13.524,678', array('locale' =&gt; $locale));

// will return 13524
print $number;
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.integer.localize"></a>25.3.8. Integer point value localization</h3></div></div></div>
<p>
            <code class="code">toInteger($value, array $options = array())</code> can localize integer values. This function will
            return a localized string of the given number.
        </p>
<div class="example">
<a name="zend.locale.integer.localize.example-1"></a><p class="title"><b>Example 25.33. Integer value localization</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
$number = Zend_Locale_Format::toInteger(13547.3655, array('locale' =&gt; $locale));

// will return 13.547
print $number;
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.integer.test"></a>25.3.9. Integer value testing</h3></div></div></div>
<p>
            <code class="code">isInteger($value, array $options = array())</code> checks if a given string is a integer value and
            returns true or false.
        </p>
<div class="example">
<a name="zend.locale.integer.test.example-1"></a><p class="title"><b>Example 25.34. Integer value testing</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('de_AT');
if (Zend_Locale_Format::isInteger('13.445', array('locale' =&gt; $locale)) {
    print "integer";
} else {
    print "not a integer";
}
            </pre></div>
</div>
<br class="example-break">
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="zend.locale.numbersystems"></a>25.3.10. Numeral System Conversion</h3></div></div></div>
<p>
            <code class="code">Zend_Locale_Format::convertNumerals()</code> converts digits between different
            <a href="http://en.wikipedia.org/wiki/Arabic_numerals" target="_top">numeral systems</a>
            , including the standard Arabic/European/Latin numeral system (0,1,2,3,4,5,6,7,8,9), not to be confused with
            <a href="http://en.wikipedia.org/wiki/Eastern_Arabic_numerals" target="_top">Eastern Arabic numerals</a>
            sometimes used with the Arabic language to express numerals. Attempts to use an unsupported numeral system
            will result in an exception, to avoid accidentally performing an incorrect conversion due to a spelling
            error. All characters in the input, which are not numerals for the selected numeral system, are copied to
            the output with no conversion provided for unit separator characters.  <code class="code">Zend_Locale*</code> components
            rely on the data provided by CLDR (see their
            <a href="http://unicode.org/cldr/data/diff/supplemental/languages_and_scripts.html?sortby=date" target="_top">
                list of scripts grouped by language</a>).
        </p>
<p>
            In CLDR and hereafter, the Europena/Latin numerals will
            be referred to as "Latin" or by the assigned 4-letter code "Latn".
            Also, the CLDR refers to this numeral systems as "scripts".
        </p>
<p>
            Suppose a web form collected a numeric input expressed using Eastern Arabic digits "١‎٠٠".
            Most software and PHP functions expect input using Arabic numerals. Fortunately, converting this input
            to it's equivalent Latin numerals "100" requires little effort using
            <code class="code">convertNumerals($inputNumeralString, $sourceNumeralSystem, $destNumeralSystem)</code>
            , which returns the <code class="code">$input</code> with numerals in the script <code class="code">$sourceNumeralSystem</code>
            converted to the script <code class="code">$destNumeralSystem</code>.
        </p>
<div class="example">
<a name="zend.locale.numbersystems.example-1"></a><p class="title"><b>Example 25.35. Converting numerals from Eastern Arabic scripts to European/Latin scripts</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$arabicScript = "١‎٠٠";   // Arabic for "100" (one hundred)
$latinScript = Zend_Locale_Format::convertNumerals($arabicScript, 'Arab', 'Latn');

print "\nOriginal:   " . $arabicScript;
print "\nNormalized: " . $latinScript;
            </pre></div>
</div>
<br class="example-break"><p>
            Similarly, any of the supported numeral systems may be converted to any other supported numeral system.
        </p>
<div class="example">
<a name="zend.locale.numbersystems.example-2"></a><p class="title"><b>Example 25.36. Converting numerals from Latin script to Eastern Arabic script</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
require_once 'Zend/Locale.php';

$latinScript = '123';
$arabicScript = Zend_Locale_Format::convertNumerals($latinScript, 'Latn', 'Arab');

print "\nOriginal:  " . $latinScript;
print "\nLocalized: " . $arabicScript;
            </pre></div>
</div>
<br class="example-break"><div class="example">
<a name="zend.locale.numbersystems.example-3"></a><p class="title"><b>Example 25.37. Getting 4 letter CLDR script code using a native-language name of the script</b></p>
<div class="example-contents"><pre class="programlisting">&lt;?php
function getScriptCode($scriptName, $locale)
{
    $scripts2names = Zend_Locale_Data::getList($locale, 'script');
    $names2scripts = array_flip($scripts2names);
    return $names2scripts[$scriptName];
}
echo getScriptCode('Latin', 'en'); // outputs "Latn"
echo getScriptCode('Tamil', 'en'); // outputs "Taml"
echo getScriptCode('tamoul', 'fr'); // outputs "Taml"
            </pre></div>
</div>
<br class="example-break"><div class="sect3" lang="en">
<div class="titlepage"><div><div><h4 class="title">
<a name="zend.locale.appendix.numberscripts.supported"></a>25.3.10.1. List of supported numeral systems</h4></div></div></div>
<p>
                </p>
<div class="table">
<a name="zend.locale.appendix.numberscripts.supported.table"></a><p class="title"><b>Table 25.5. List of supported numeral systems</b></p>
<div class="table-contents"><table summary="List of supported numeral systems" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Notation Name</th>
<th>Script</th>
</tr></thead>
<tbody>
<tr>
<td>Arabic</td>
<td>Arab</td>
</tr>
<tr>
<td>Balinese</td>
<td>Bali</td>
</tr>
<tr>
<td>Bengali</td>
<td>Beng</td>
</tr>
<tr>
<td>Devanagari</td>
<td>Deva</td>
</tr>
<tr>
<td>Gujarati</td>
<td>Gujr</td>
</tr>
<tr>
<td>Gurmukhi</td>
<td>Guru</td>
</tr>
<tr>
<td>Kannada</td>
<td>Knda</td>
</tr>
<tr>
<td>Khmer</td>
<td>Khmr</td>
</tr>
<tr>
<td>Lao</td>
<td>Laoo</td>
</tr>
<tr>
<td>Limbu</td>
<td>Limb</td>
</tr>
<tr>
<td>Malayalam</td>
<td>Mlym</td>
</tr>
<tr>
<td>Mongolian</td>
<td>Mong</td>
</tr>
<tr>
<td>Myanmar</td>
<td>Mymr</td>
</tr>
<tr>
<td>New_Tai_Lue</td>
<td>Talu</td>
</tr>
<tr>
<td>Nko</td>
<td>Nkoo</td>
</tr>
<tr>
<td>Oriya</td>
<td>Orya</td>
</tr>
<tr>
<td>Tamil</td>
<td>Taml</td>
</tr>
<tr>
<td>Telugu</td>
<td>Telu</td>
</tr>
<tr>
<td>Thai</td>
<td>Tale</td>
</tr>
<tr>
<td>Tibetan</td>
<td>Tibt</td>
</tr>
</tbody>
</table></div>
</div>
<p><br class="table-break">
            </p>
</div>
</div>
</div>
<div class="navfooter"><table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="zend.locale.functions.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="zend.locale.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="zend.locale.date.datesandtimes.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">25.2. Using Zend_Locale </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> 25.4. Working with Dates and Times</td>
</tr>
</table></div>
<div class="revinfo"></div>
</body>
</html>
